package com.lin.controller.admin;

import com.lin.commons.Result;
import com.lin.dto.UserDTO;
import com.lin.service.AdminService;
import com.lin.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Created by Lin Weihong
 * @Time on 2021/11/26 11:27
 */
@RestController
@CrossOrigin
public class AdminLoginController {

    @Autowired
    private AdminService adminService;

    @PostMapping("/admin/login")
    public Result login(@RequestBody UserDTO userDTO) {
        int login = adminService.login(userDTO);
        if (login == 1) {
            return Result.success();
        }else {
            return Result.failure("登录有误，请重新尝试");
        }
    }


}
